package rs.dalao.syc.passport.dao.persist.repository.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import rs.dalao.syc.passport.dao.persist.mapper.DoctorMapper;
import rs.dalao.syc.passport.dao.persist.mapper.UserMapper;
import rs.dalao.syc.passport.dao.persist.repository.IUserRepository;
import rs.dalao.syc.passport.pojo.entity.Doctor;
import rs.dalao.syc.passport.pojo.entity.User;
import rs.dalao.syc.passport.pojo.vo.LoginInfoVO;
import rs.dalao.syc.passport.pojo.vo.LoginRegVO;

@Repository
public class UserRepositoryImpl implements IUserRepository {
    @Autowired
    private UserMapper userMapper;

    @Autowired
    private DoctorMapper doctorMapper;

    @Override
    public LoginInfoVO getInfo(String userName) {
        return userMapper.getInfo(userName);
    }

    @Override
    public LoginRegVO getRegInfo(String userName) {
        return userMapper.getRegInfo(userName);
    }

    //根据电话查找用户是否存在
    @Override
    public LoginInfoVO getInfoByPhone(String phone) {
        return userMapper.getInfoByPhone(phone);
    }

    //用户注册
    @Override
    public int userReg(User user) {
        return userMapper.insert(user);
    }


    //医生注册
    @Override
    public int doctorReg(Doctor doctor) {
        return doctorMapper.insert(doctor);
    }
}
